/* $Id: user.cc jjs $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 2 or any
   later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/
#define DEBUG_ROUTINE "user"

#include "user.h"
#include "../general/log.h"
#include "../general/misc.h"

void user::save(channel *ch)
{
	ch->write("username", username);
	ch->write("password", password);
	ch->write("session", session);
}

void load_user(channel *ch)
{
	if (ch->key=="username") {
		user u;
		u.username=ch->value;
		if (ch->peek("password")) {
			ch->next();
			u.password=ch->value;
		}
		if (ch->peek("session")) {
			ch->next();
			u.session=ch->value.c_str();
		}
		users[u.username]=u;
	}
}

map<string, user> users;
